home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Freeware / Gobby 0.4.7 / gobby-0.4.7.exe / {app} / share / gtksourceview-2.0 / language-specs / ocaml.lang < prev    next >
Extensible Markup Language  |  2008-09-09  |  8KB  |  238 lines

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!-- vim: set sts=2 sw=2: -->
  3. <!--
  4.  
  5.  Author: Eric Cooper <ecc@cmu.edu>
  6.  Copyright (C) 2007 Eric Cooper <ecc@cmu.edu>
  7.  Copyright (C) 2007 Eric Norige <thelema314@gmail.com>
  8.  
  9.  This library is free software; you can redistribute it and/or
  10.  modify it under the terms of the GNU Library General Public
  11.  License as published by the Free Software Foundation; either
  12.  version 2 of the License, or (at your option) any later version.
  13.  
  14.  This library is distributed in the hope that it will be useful,
  15.  but WITHOUT ANY WARRANTY; without even the implied warranty of
  16.  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  17.  Library General Public License for more details.
  18.  
  19.  You should have received a copy of the GNU Library General Public
  20.  License along with this library; if not, write to the
  21.  Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  22.  Boston, MA 02111-1307, USA.
  23.  
  24. -->
  25. <language id="objective-caml" _name="Objective Caml" version="2.0" _section="Sources">
  26.   <metadata>
  27.     <property name="mimetypes">text/x-ocaml</property>
  28.     <property name="globs">*.ml;*.mli;*.mll;*.mly</property>
  29.     <property name="block-comment-start">(*</property>
  30.     <property name="block-comment-end">*)</property>
  31.   </metadata>
  32.  
  33.   <styles>
  34.     <style id="comment" _name="Comment" map-to="def:comment"/>
  35.     <style id="ocamldoc" _name="Ocamldoc Comments" map-to="def:note"/>
  36.     <style id="base-n-integer" _name="Base-N Integer" map-to="def:base-n-integer"/>
  37.     <style id="floating-point" _name="Floating Point number" map-to="def:floating-point"/>
  38.     <style id="decimal" _name="Decimal number" map-to="def:decimal"/>
  39.     <style id="string" _name="String" map-to="def:string"/>
  40.     <style id="keyword" _name="Keyword" map-to="def:keyword"/>
  41.     <style id="meta-keyword" _name="Type, module or object keyword" map-to="def:keyword"/>
  42.     <style id="fun-keyword" _name="Builtin-function keyword" map-to="def:keyword"/>
  43.     <style id="type" _name="Data Type" map-to="def:type"/>
  44.     <style id="label" _name="Labeled argument" map-to="def:type"/>
  45.     <style id="poly-variant" _name="Polymorphic Variant" map-to="def:type"/>
  46.     <style id="variant" _name="Variant Constructor" map-to="def:type"/>
  47.     <style id="type-var" _name="Type Variable" map-to="def:type"/>
  48.     <style id="module" _name="Module Path" map-to="def:type"/>
  49.     <style id="escape" _name="Escaped Character" map-to="def:special-char"/>
  50.     <style id="boolean" _name="Boolean value" map-to="def:boolean"/>
  51.     <style id="error" _name="Error" map-to="def:error"/>
  52.   </styles>
  53.  
  54.   <definitions>
  55.     <define-regex id="cap-ident">\b[A-Z][A-Za-z0-9_']*</define-regex>
  56.     <define-regex id="low-ident">\b[a-z][A-Za-z0-9_']*</define-regex>
  57.     <define-regex id="char-esc">\\((\\|"|'|n|t|b|r)|[0-9]{3}|x[0-9a-fA-F]{2})</define-regex>
  58.     <context id="escape-seq" style-ref="escape">
  59.       <match>\%{char-esc}</match>
  60.     </context>
  61.     <!-- here's the main context -->
  62.     <context id="objective-caml">
  63.       <include>
  64.     <context id="ocamldoc" style-ref="ocamldoc">
  65.       <start>\(\*\*</start>
  66.       <end>\*\)</end>
  67.       <include>
  68.         <context id="comment-in-comment" style-ref="comment">
  69.           <start>\(\*</start>
  70.           <end>\*\)</end>
  71.           <include>
  72.         <context ref="string"/>
  73.         <context ref="comment-in-comment"/>
  74.         <context ref="def:in-comment:*"/>
  75.           </include>
  76.         </context>
  77.         <context ref="string"/>
  78.         <context ref="def:in-comment:*"/>
  79.       </include>
  80.     </context>
  81.     <context id="comment" style-ref="comment">
  82.       <start>\(\*</start>
  83.       <end>\*\)</end>
  84.       <include>
  85.         <context ref="string"/>
  86.         <context ref="comment-in-comment"/>
  87.         <context ref="def:in-comment:*"/>
  88.       </include>
  89.     </context>
  90.     <context id="decimal" style-ref="decimal">
  91.       <match>[-]?[0-9][0-9_]*[lLn]?</match>
  92.     </context>
  93.     <context id="hex-number" style-ref="base-n-integer">
  94.       <match>[-]?0[xX][0-9A-Fa-f][0-9A-Fa-f_]*[lL]?</match>
  95.     </context>
  96.     <context id="octal-number" style-ref="base-n-integer">
  97.       <match>[-]?0[oO][0-7][0-7_]*[lL]?</match>
  98.     </context>
  99.     <context id="binary-number" style-ref="base-n-integer">
  100.       <match>[-]?0[bB][01][01_]*[lL]?</match>
  101.     </context>
  102.     <context id="floating-point-number" style-ref="floating-point">
  103.       <match>[-]?[0-9][0-9_]*(\.[0-9_]*)?([Ee][+-]?[0-9][0-9_]*)?</match>
  104.     </context>
  105.     <context id="label" style-ref="label">
  106.       <match>[~?]\%{low-ident}</match>
  107.     </context>
  108.     <context id="poly-variant" style-ref="poly-variant">
  109.       <match>`\%{cap-ident}</match>
  110.     </context>
  111.     <context id="modpath" style-ref="module">
  112.       <!-- include final '.'?  At the moment, no.  -->
  113.       <match>\%{cap-ident}(\.\%{cap-ident})*(?=\.)</match>
  114.     </context>
  115.     <context id="variant" style-ref="variant">
  116.       <match>\%{cap-ident}</match>
  117.     </context>
  118.     <context id="string" style-ref="string">
  119.       <start>"</start>
  120.       <end>"</end>
  121.       <include>
  122.         <context ref="escape-seq"/>
  123.       </include>
  124.     </context>
  125.     <context id="character-constant" style-ref="string">
  126.       <match>('\%{char-esc}')|('[^\\']')</match>
  127.     </context>
  128.     <context id="type-var" style-ref="type-var">
  129.       <match>'\%{low-ident}</match>
  130.     </context>
  131.     <context id="arraylit">
  132.       <start>\[\|</start>
  133.       <end>\|\]</end>
  134.       <include>
  135.         <context ref="objective-caml"/>
  136.       </include>
  137.     </context>
  138.     <context id="badarray" style-ref="error" extend-parent="false">
  139.       <match>\|\]</match>
  140.     </context>
  141.     <context id="listlit">
  142.       <start>\[</start>
  143.       <end>(?<!\|)\]</end>
  144.       <include>
  145.         <context ref="objective-caml"/>
  146.       </include>
  147.     </context>
  148.     <context id="badlist" style-ref="error" extend-parent="false">
  149.       <match>\]</match>
  150.     </context>
  151.     <context id="boolean-constant" style-ref="boolean">
  152.       <keyword>true</keyword>
  153.       <keyword>false</keyword>
  154.     </context>
  155.     <!-- Flow control & common keywords -->
  156.     <context id="keywords" style-ref="keyword">
  157.       <keyword>and</keyword>
  158.       <keyword>assert</keyword>
  159.       <keyword>begin</keyword>
  160.       <keyword>do</keyword>
  161.       <keyword>done</keyword>
  162.       <keyword>downto</keyword>
  163.       <keyword>else</keyword>
  164.       <keyword>end</keyword>
  165.       <keyword>for</keyword>
  166.       <keyword>fun</keyword>
  167.       <keyword>function</keyword>
  168.       <keyword>if</keyword>
  169.       <keyword>in</keyword>
  170.       <keyword>let</keyword>
  171.       <keyword>match</keyword>
  172.       <keyword>rec</keyword>
  173.       <keyword>then</keyword>
  174.       <keyword>to</keyword>
  175.       <keyword>try</keyword>
  176.       <keyword>val</keyword>
  177.       <keyword>when</keyword>
  178.       <keyword>while</keyword>
  179.       <keyword>with</keyword>
  180.     </context>
  181.     <!-- types, objects and modules -->
  182.     <context id="meta-words" style-ref="meta-keyword">
  183.       <keyword>as</keyword>
  184.       <keyword>class</keyword>
  185.       <keyword>constraint</keyword>
  186.       <keyword>exception</keyword>
  187.       <keyword>external</keyword>
  188.       <keyword>functor</keyword>
  189.       <keyword>include</keyword>
  190.       <keyword>inherit</keyword>
  191.       <keyword>initializer</keyword>
  192.       <keyword>method</keyword>
  193.       <keyword>module</keyword>
  194.       <keyword>mutable</keyword>
  195.       <keyword>new</keyword>
  196.       <keyword>object</keyword>
  197.       <keyword>of</keyword>
  198.       <keyword>open</keyword>
  199.       <keyword>private</keyword>
  200.       <keyword>struct</keyword>
  201.       <keyword>sig</keyword>
  202.       <keyword>type</keyword>
  203.       <keyword>virtual</keyword>
  204.     </context>
  205.     <context id="function-keywords" style-ref="fun-keyword">
  206.       <!-- function-like keywords -->
  207.       <keyword>asr</keyword>
  208.       <keyword>land</keyword>
  209.       <keyword>lazy</keyword>
  210.       <keyword>lor</keyword>
  211.       <keyword>lsl</keyword>
  212.       <keyword>lsr</keyword>
  213.       <keyword>lxor</keyword>
  214.       <keyword>mod</keyword>
  215.       <keyword>or</keyword>
  216.       <!-- from pervasives, but same as others -->
  217.       <keyword>lnot</keyword>
  218.     </context>
  219.     <context id="types" style-ref="type">
  220.       <!-- pervasives types -->
  221.       <keyword>option</keyword>
  222.       <keyword>ignore</keyword>
  223.       <keyword>ref</keyword>
  224.       <keyword>array</keyword>
  225.       <keyword>bool</keyword>
  226.       <keyword>char</keyword>
  227.       <keyword>float</keyword>
  228.       <keyword>int</keyword>
  229.       <keyword>list</keyword>
  230.       <keyword>string</keyword>
  231.       <keyword>unit</keyword>
  232.       <!-- note: Some and None are highlighted as variants -->
  233.     </context>
  234.       </include>
  235.     </context>
  236.   </definitions>
  237. </language>
  238.